<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace common\traits;

/**
 * Description of SoftDeleting
 *
 * @author emhome
 */
trait SoftDeleting {

    /**
     * delete
     * @param boolean $hard 是否实际删除
     * @return string
     */
    public function delete($hard = false) {
        if ($hard == false && $this->hasAttribute('deleted_at')) {
            $this->deleted_at = time();
            return $this->save();
        }
        return parent::delete();
    }

}
